package com.woniuxy.qiantai.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//用户下单给商家邮箱发送订单信息
@Configuration
public class OrderEmailMQConfig {

    //声明以下内容:  交换机   队列   以及交换和队列的绑定关系
    //交换机
    @Bean
    public DirectExchange OrderEmailExchange(){
        return new DirectExchange("OrderEmailExchange");
    }

    //队列
    @Bean
    public Queue OrderEmailQueue(){
        return new Queue("OrderEmailQueue");
    }

    //交换机要和队列绑定到一起
    @Bean
    public Binding OrderEmailBinding(){
        return BindingBuilder.bind(OrderEmailQueue())
                .to(OrderEmailExchange())
                .with("OrderEmail");
    }



}
